package study.rpc.sofa.bolt.support.server;

import com.alipay.remoting.ConnectionEventProcessor;
import com.alipay.remoting.rpc.RpcServer;
import study.rpc.sofa.bolt.support.processor.ServerConnectionProcessor;
import study.rpc.sofa.bolt.support.processor.ServerUserProcessor;

public class BoltServer {

    private RpcServer server;

    private ServerUserProcessor serverUserProcessor = new ServerUserProcessor();

    private ConnectionEventProcessor serverConnectProcessor = new ServerConnectionProcessor();

    public BoltServer(int port) {
        server = new RpcServer(port);
    }

    public void start() {
//        server.addConnectionEventProcessor(ConnectionEventType.CONNECT, serverConnectProcessor);
        server.registerUserProcessor(serverUserProcessor);
        server.startup();
    }

    public void shutdown() {
        server.shutdown();
    }
}
